﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using _1Dot9MasterData;

namespace _1Dot9MasterDac
{
    public class GuestBookDac : MasterDacBase
    {
/// 생성자 DB 연결 코드
        /// </summary>
        public GuestBookDac()
        {
            this.ConnectionStrings = "thiagoms";
        }

        public GuestBookDac(string _connectionStrings)
        {
            this.ConnectionStrings = _connectionStrings;
        }

        #region 게시판 입력
        /// <summary>
        /// 게시판 입력 
        /// </summary>
        public int GuestBookInsert(Hashtable htParams)
        {
            DbCommand dbCommand = this.DbAccess.GetStoredProcCommand("dbo.UP_GuestBook_Insert");

            SetParameter(htParams, dbCommand);

            return this.DbAccess.ExecuteNonQuery(dbCommand);
        }
        #endregion

        #region 파라미터 셋팅
        private void SetParameter(Hashtable htParams, DbCommand dbCommand)
        {
            if (htParams != null)
            {
                foreach (string strKey in htParams.Keys)
                {
                    if (htParams[strKey] == null) continue;
                    this.DbAccess.AddInParameter(dbCommand, strKey, TypeAlias.GetDbType(htParams[strKey].GetType()), htParams[strKey]);
                }
            }
        }
        #endregion

        #region 게시판 전체조회
        public DataSet GuestBookSelect(Hashtable htParams)
        {
            DbCommand dbCommand = this.DbAccess.GetStoredProcCommand("UP_GuestBook_Select");
            SetParameter(htParams, dbCommand);
            return this.DbAccess.ExecuteDataSet(dbCommand);

        }
        #endregion 


    }
}
